package hxy.dragon.ktor.router

import hxy.dragon.ktor.service.GroupService
import io.ktor.http.HttpStatusCode
import io.ktor.server.application.Application
import io.ktor.server.application.install
import io.ktor.server.response.respond
import io.ktor.server.response.respondText
import io.ktor.server.routing.get
import io.ktor.server.routing.route
import io.ktor.server.routing.routing
import org.koin.ktor.ext.inject

/**
 * @description
 * @author HOX4SGH
 * @date 2024/10/10
 */
@io.ktor.resources.Resource("/api")
class Groups(val msg: String)

fun Application.configureGroupRouter() {

    install(io.ktor.server.resources.Resources)

    // Lazy inject GroupService 这里也是通过Koin来弄的。 这里也会延迟初始化，用到的时候才开始初始化、Lazy value not initialized yet.
    val service by inject<GroupService>()

    routing {
        route("/") {
            get("group") {
                val message = service.getDefaultUser()
                call.respond(HttpStatusCode.OK, message)
            }
        }

//        https://api.ktor.io/ktor-shared/ktor-resources/io.ktor.resources/-resource/index.html
//      有待研究   https://mp.weixin.qq.com/s/kaLFh78kp2U9q-Yd3AgdnQ
//        get<Groups> {
//            call.respondText("")
//        }
    }


}